#!/usr/bin/env jsrun

var i = 0;
var max = +arguments[1] || 10;

var total_t0 = +new Date;
make(function(){
	var x='', t0, t, url, stri;
	var c = new Curl;
	var _i;
	while (i < max) {
		_i = i++;
		stri = ('' + (100000 + _i)).substr(1);
		//url = 'http://localhost/test.txt?r=' + stri;
		url = 'http://localhost:51234/test.txt?r=' + stri;
		c.setopt(c.CURLOPT_URL, url);
		c.setopt(c.CURLOPT_FOLLOWLOCATION, 1);
		t0 = +new Date;
		x = c.perform();
		t = +new Date - t0;
		//print(url + ': resp. length = ' + x.length + ' bytes, time = ' + t + ' ms.');
		sleep(5);
	}
}, 100);
var total_t = +new Date - total_t0;

print('DONE. Average time per request (ms): ' + total_t / max);







